<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Video extends CI_Controller {
	
	public function index() { }

	public function getVideo($vId) {
		$this->load->model('Model_video');
		$cursor = $this->Model_video->getVideo($vId);

		// Conver mongoCursor to JSON
		echo json_encode($cursor);	
	}

	public function addVideo() {
		$v = $this->input->post('data');
		$this->load->model('Model_video');

		$cc = $this->Model_video->insert_video($v['_id'], $v['cat'], $v['description']);
		print_r($cc);
	}
	
	public function getVideos() {
		$this->load->model('Model_video');
		$cursor = $this->Model_video->getVideos();
		$cursor->sort(array('description' => 1));

		echo json_encode(iterator_to_array($cursor));
	}

}
